<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>酒店后台管理系统</title>
  <link rel="stylesheet" href="css/layui.css">
  <script src="js/jquery.min.js"></script>
  <script>
	$(function(){
		
		var url = "ws://192.168.40.228:8080/WebSocketHandler/";
		var ws = null;
		//连接服务器
		var userName = $("#userName").val();
		url = url + userName; //传递用户名
		//创建对象，连接服务器
		ws=new WebSocket(url);
		//给ws对象绑定事件
		//连接事件
		ws.onopen = function(){
			console.info("连接服务器成功");
		}
		//接收到消息
		ws.onmessage = function(result){
			alert(result.data);
		}
		//关闭连接
		ws.onclose = function(){
			alert("断开连接");
		}
		
		$("#pass_message").click(function(){
			var message=$("#pass_message").val();
			alert(message);
			if(ws!=null){
				ws.send(message); //发送消息
			}
		})
		
		$("#nopass_message").click(function(){
			var message=$("#nopass_message").val();
			alert(message);
			if(ws!=null){
				ws.send(message); //发送消息
			}
		})
			
		//断开连接
		$("#cancel").click(function(){
			if(ws!=null){
				ws.close();
			}
		});	

		$.ajax({
			url:"/order/find",
			type:"post",
			success:function(data){
				var order = $("");
				for(var i=0;i<data.length;i++){
					var table_class =$('<div class="table_class" style="width:1000px; margin-left: 50px;"></div>');
					var table=$("<table class='layui-table' lay-skin='line' lay-size='sm'></table>");
					var colgroup=$("<colgroup></colgroup>").text("<col width='150'>"
							+"<col width='200'>"
							+"<col>");
					var thead=$("<thead></thead>");
					var tr = $("<tr></tr>");
					var th1=$("<th style='width: 150px;'></th>").text("订单号");
					var th2 = $("<th></th>").text("");
					var th3 = $("<th></th>").text("");
					var th4 = $("<th></th>").text("");
					var th5 = $("<th></th>").text("");
					var th6 = $("<th></th>").text("");
					table_class.append(table);
					tr.append(th1);
				    tr.append(th2);
				    tr.append(th3);
				    tr.append(th4);
				    tr.append(th5);
				    tr.append(th6);
				    thead.append(tr);
					var tbody=$("<tbody></tbody>");
					for(var j=0;j<data[i].orderDetails.leng;j++){
						var tr1 = $("<tr></tr>");
					    var td1=$("<td class='rtname_btn'></td>").text(data[i].orderDetails[j].rtname);
					    alert(data[i].orderDetails[j].rtname);
					    var td2=$("<td class='rwindow'></td>").text(data[i].orderDetails[j].rtname);
					    var td3=$("<td class='rfood'></td>").text(data[i].orderDetails[j].rtname);
					    var td4=$("<td class='rspring'></td>").text(data[i].orderDetails[j].rtname);
					    var td5=$("<td style='color: rgb(238 44 44);font-size: 15px; font-weight: 600;' class='rprice'></td>").text(data[i].orderDetails[j].rtname);
					    var td6=$("<td class='rnumber'></td>" ).text(data[i].orderDetails[j].rtname);
					    tr1.append(td1);
					    tr1.append(td2);
					    tr1.append(td3);
					    tr1.append(td4);
					    tr1.append(td5);
					    tr1.append(td6);
					    tbody.append(tr1);
					}
					table.append(thead);
					table.append(tbody);
					order.append(table_class);
				}
				$("#order_message").html(order);
			}
		})
	})
  </script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo">酒店后台管理系统</div>
    <!-- 头部区域（可配合layui已有的水平导航） -->
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item">
        <a href="javascript:;">
          <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
          贤心
        </a>
        <dl class="layui-nav-child">
          <!-- <dd><a href="">消息<span class="layui-badge">99+</span></a></dd> -->
        </dl>
      </li>
      <li class="layui-nav-item"><a href="logout">退了</a></li>
    </ul>
  </div>
  
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
     <ul class="layui-nav layui-nav-tree"  lay-filter="test">
        <li class="layui-nav-item layui-nav-itemed">
          <a class="" href="javascript:;">订单管理</a>
          <dl class="layui-nav-child">
            <dd><a href="/html/offline.html">线下开单</a></dd>
            <dd><a href="/checkin.html">线下开房</a></dd>
            <dd><a href="/html/checkout.html">宾客结账</a></dd>
            <dd><a href="/html/order.html">订单管理</a></dd>
          </dl>
        </li>
       <li class="layui-nav-item">
          <a href="javascript:;">营业查询</a>
          <dl class="layui-nav-child">
            <dd><a href="/selguest.html">入住宾客查询</a></dd>
            <dd><a href="/turnover.html">日/月营业查询</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item">
          <a href="javascript:;">系统设置</a>
          <dl class="layui-nav-child">
            <dd><a href="/vip.html">VIP设置</a></dd>
        		<dd><a href="/discount.html">计费设置</a></dd>
        		<dd><a href="/room.html">房间设置</a></dd>
				<dd><a href="/admin.html">操作员设置</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item"><a href="/html/confirm.html">推送消息</a></li>
      </ul>
    </div>
  </div>
  
  <div class="layui-body">
    <!-- 内容主体区域 -->
    <input type="hidden" id="userName" value="后台">
		<div class="layui-order-message">
			订单信息
		<hr class="layui-bg-green">
		</div>
		<div id="order_message">
		
		</div>
		<div class="table_class" style="width:1000px; margin-left: 50px;">
			<table class="layui-table" lay-skin="line">
				<colgroup>
					<col width="150">
					<col width="200">
					<col>
				</colgroup>
				<thead>
					<tr>
						<th style="width: 150px;">订单号</th>
						<th></th>
						<th></th>
						<th></th>
						<th></th>
						<th></th>
						<th><button type="button" class="layui-btn layui-btn-xs layui-btn-danger" id="pass_message" value="通过">通过</button><button type="button" class="layui-btn layui-btn-xs layui-btn-danger" id="nopass_message" value="清空">清空</button></th>
					</tr> 
				</thead>
				<tbody>
					<tr id="roomtype">
						<td>贤心</td>
						<td style="color: rgb(238 44 44);font-size: 15px; font-weight: 600;">￥1000</td>
						<td>张三</td>
						<td>12345678</td>
						<th>入住时间</th>
						<th>预计退房时间</th>
						<th>实际退房时间</th>
					</tr>
					<tr>
						<td>许闲心</td>
						<td style="color: rgb(238 44 44);font-size: 15px;font-weight: 600;">￥1000</td>
						<td>李四</td>
						<td>12345678</td>
						<th>入住时间</th>
						<th>预计退房时间</th>
						<th>实际退房时间</th>
					</tr>
				</tbody>
			</table>
		</div>
  
  <div class="layui-footer">
    <!-- 底部固定区域 -->
    © 版权归酒店所有
  </div>
</div>
<script src="layui.js"></script>
<script>
//JavaScript代码区域
layui.use('element', function(){
  var element = layui.element;
  
});
</script>
</body>
</html>